public class panel1 extends JPanel implements ActionListener(){
private panel2 p2=new panel2();
private JButton button;
public panel1(){
button=new JButton("open panel2");
add(button,BorderLayout.BEFORE_FIRST_LINE);
button.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent ae) {
add(p2);
}
});
}
}Open another panel inside another panel after pressing button
1320
04-Dec-2015
I have been getting an error saying that i didn't add some methods(the action performed) but i already did. I'm having trouble opening the panel2.
Anonymous User
04-Dec-2015